if orders and not orders.SetStopLots then


function orders:SetStopLots(order, qty)
	if self:IsOrder(order)
		and not self.stop_replaced[order.order_num]
		and bit.band(order.flags, 3) == 1		-- active
	then
		qty = int(qty)
	
		self.log("SetStopLots " .. qty, order)
			
		if qty <= 0 then
			return self:KillStopOrder(order)
		else
			local transaction = self:KillStopTransaction(order)
			
			transaction.qty = qty
			
			local next_transaction =	order.stop_order_type == 10 and self:ActivatedTakeStopTransaction(transaction)
										or order.stop_order_type == 7 and self:ActivatedStopTransaction(transaction)
										or order.stop_order_type == 9 and self:TakeStopTransaction(transaction)
										or order.stop_order_type == 1 and self:StopTransaction(transaction)
				
			local limit
			local limit_transaction
			local next_limit_transaction
			
			if order.stop_order_type == 1		-- stop
			then
				limit = self:GetTakeLimit(order)
				if limit then
					limit_transaction = self:KillOrderTransaction(limit)
					limit.ex__ = {tp = limit.price}
					limit.qty = qty
					next_limit_transaction = self:TakeLimitTransaction(limit)
					next_limit_transaction.ex__.take_limit = limit.order_num
					next_transaction.ex__.take_limit = order.order_num
				end
			end
			
			self.stop_replaced[order.order_num] = lib:tickseconds()
		
			return self:sendTransaction(transaction, next_transaction, limit_transaction, next_limit_transaction)
		end
	end
end


end -- of file
